<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="order_sn"  placeholder="请输入订单号" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>

                <div class="layui-card-header">

                    <button class="layui-btn" onclick="xadmin.open('添加出库单','addorder',800,600)"><i class="layui-icon"></i>添加</button>
                </div>


            </div>
        </div>
    </div>
</div>
<div class="layui-card-body layui-table-body layui-table-main">
    <table class="layui-table layui-form">
        <thead>
        <tr>
            <th>入库单单号</th>
            <th>创建时间</th>
            <th>确认时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="v"}
        <tr>

            <td>{$v.order_sn}</td>
            <td>{$v.time|date='Y-m-d H:i:s'}</td>
            <td>{if $v.send_time}{$v.send_time|date='Y-m-d H:i:s'}{/if}</td>
            <td>
                {if $v.status == 1}
                <span class="layui-btn layui-btn-normal layui-btn-mini">等待选择商品</span>
                {elseif $v.status==2}
                <span class="layui-btn">待确认</span>
                {elseif $v.status==3}
                <span class="layui-btn">待入库</span>
                {elseif $v.status==4}
                <span class="layui-btn">已完成</span>
                {/if}
            </td>
            <td class="td-manage">
                {if $v.status==1}
                    <button type="button" class="layui-btn layui-btn-primary" onclick="xadmin.open('编辑','changegoods?id={$v.id}',)">选择商品</button>
                {/if}
                {if $v.status==2}
                    <button type="button" class="layui-btn layui-btn-primary" onclick="changeOrder({$v.id},3)">确认采购单</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="xadmin.open('编辑','changegoods?id={$v.id}',)">管理商品</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="delware({$v.id})"> <i class="layui-icon">&#xe640;</i>删除</button>

                {/if}
                {if $v.status==3}
                <button type="button" class="layui-btn layui-btn-primary" onclick="changeOrder({$v.id},4)">确认入库完成</button>
                <button type="button" class="layui-btn layui-btn-primary" onclick="xadmin.open('查看入库情况','check?id={$v.id}',)">查看入库情况</button>
                {/if}
                {if $v.status==4}
                <button type="button" class="layui-btn layui-btn-disabled">完成入库</button>
                {/if}
<!--                <button type="button" onclick="xadmin.open('查看订单','order/?id={$v.id}',1000,600)" class="layui-btn layui-btn-warm">打印入库单</button>-->

        </tr>
        {/volist}
        </tbody>
    </table>
</div>
<script>
    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;


        // 监听全选
        form.on('checkbox(checkall)', function(data){

            if(data.elem.checked){
                $('tbody input').prop('checked',true);
            }else{
                $('tbody input').prop('checked',false);
            }
            form.render('checkbox');
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });


    });
    function changeOrder(id,status){
        $.ajax({
            url:'changeOrder',
            type:'post',
            data:{id:id,status:status},
            dataType:"json",
            success:function (res) {
                if (res.code==1){
                    window.location.href=""
                }else if(res.code == 2){
                    layer.alert(res.msg, {
                            icon: 6
                        },
                        function() {
                            //关闭当前frame
                            xadmin.close();

                            // 可以对父窗口进行刷新
                            xadmin.father_reload();
                        });
                }  else{
                    alert("网络错误");
                }
            }
        });
    }

    /*用户-删除*/
    function delware(id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url:'delodo',
                type:'post',
                data:{id:id},
                dataType:"json",
                success:function (res) {

                }
            });
            layer.msg('已删除!',{icon:1,time:1000});
            window.location.href="";
        });
    }




</script>
</html>